/*
 * @Description:
 * @Author: Tsingwong
 * @Date: 2020-11-27 11:02:59
 * @LastEditors: Tsingwong
 * @LastEditTime: 2020-12-01 17:06:48
 */
import Axios from 'axios'
import {} from './actionType'
import * as constants from './actionType'

export const login = (account, password) => {
  return (dispatch, getState) => {
    Axios.get('/api/login', {
      params: {
        account,
        password,
      },
    }).then((res) => {
      // console.log(res)
      if (res?.data?.success) {
        const result = res.data.data
        dispatch(setLoginState(result))
      }
    })
  }
}

export const setLoginState = (params) => {
  return {
    type: constants.SET_LOGIN_STATE,
    params,
  }
}
